<?php
/**************************************
 * View class with panel
 * Brainfucker.ru (c) Oleg Illarionov
 **************************************/
include_once 'view.class.php';
class cmsview extends view {
	# Можно ли редактировать текущую страницу 	
	var $editable=true;
	
	/**
	 * Вывод панели для управления сайтом
	 * 
	 * @param string $path
	 */
	 function panel($path = 'admin/panel') {
		global $config;
		include_once('auth.class.php');
		$panelauth = new auth();
		$panelauth->setPrefix('cms');
		$panelauth -> addArray($config['users']);
		if (!$panelauth->check()) return false;
		include_once root.'/'.$path.'/index.php';
		if (isset($this->hostpanelpath) && $this->viewmode=='edit') $this->pageeditable=true;
	}
	
	/**
	 * Вывод редактируемой области
	 *
	 * @param string $path
	 */
	function area($content) {
		if ($this->pageeditable) {
			$this->editareaid++;
			$this->editpage['page']='';
			$this->editpage['text']=$content;
			
			include $this->hostpanelpath.'/template/editable.php';
		} else echo $content;
	}
	
	
	/**
	 * Выводит контент страницы
	 *
	 */
	function content() {
		//var_dump($this->editable); die();
		if ($this->pageeditable && $this->editable) {
			$this->editpage['page']=$this->file;
			$this->editpage['text']=$this->content;
			
			include $this->hostpanelpath.'/template/editcontent.php';
		} else echo $this->content;
	}
}
?>